import { Component, Input, OnChanges, OnInit } from "@angular/core";
import InfoConfig from "./info.config";
import { StadiaType } from '../one-map';

@Component({
  selector: "app-dialog-info",
  templateUrl: "./dialog-info.component.html",
  styleUrls: ["./dialog-info.component.scss"]
})
export class DialogInfoComponent implements OnChanges {
  @Input() data: any;

  infoConfig: any = {
    attrs: []
  };
  preview: boolean = false;
  previewUrl: string = '';
  picVisible: boolean = false;
  nzFooter: any = null;
  modalTitle: string = '';
  pics: any[] = [];
  mediaType: string = '';
  irrAreaType: any = {
    1: "自流灌区",
    2: "扬水灌区"
  };
  IntakeType: any = {
    1: "地表水取水站",
    2: "地下水取水站",
    3: '退（排）水站'
  };
  stadiaType: any = StadiaType;

  constructor() {}

  ngOnChanges(): void {
    // console.log(this.data);
    this.infoConfig = InfoConfig[this.data.layer];
  }

  onOpenModal(type) {
    this.modalTitle = type == 'file' ? '文件列表' : type == 'movie' ? '视频列表' : '图片列表';
    this.mediaType = type;
    this.pics = this.data.files[type];
    this.picVisible = true;
  }

  onPreview() {
    this.previewUrl = `http://10.6.181.223:9008/api/comm/file/view/${this.data.fileId}`;
    this.preview = true;
  }
}
